package com.example.spareparts.repository;

import java.util.List;
import org.apache.ibatis.annotations.*;
import com.example.spareparts.entity.SpareCategory;

@Mapper
public interface SpareCategoryRepository {
    @Select("SELECT * FROM SparePartCategories")
    List<SpareCategory> findAllSpareCategory();
    @Insert("INSERT INTO SparePartCategories (spare_part_id, device_type, importance_level) VALUES ( #{sparepartid}, #{devicetype}, #{importancelevel})")
    @Options(useGeneratedKeys = true, keyProperty = "categoryid")
    void insertSpareCategory(SpareCategory spareCategory);
    @Update("UPDATE SparePartCategories SET category_id= #{categoryid}, spare_part_id= #{sparepartid}, device_type= #{devicetype}, importance_level= #{importancelevel} WHERE category_id= #{categoryid}")
    void updateSpareCategory(SpareCategory spareCategory);
    @Delete("DELETE FROM SparePartCategories WHERE category_id= #{categoryid}")
    void deleteSpareCategory(Long categoryid);

    @Select("SELECT * FROM SparePartCategories WHERE category_id= #{categoryid}")
    SpareCategory findSpareCategoryById(Long categoryid);
    @Select("SELECT * FROM SparePartCategories WHERE spare_part_id= #{sparepartid}")
    List<SpareCategory> findSpareCategoryBySparePartId(Long sparepartid);

}
